home *** CD-ROM | disk | FTP | other *** search
- Path: odin.visigenic.com!news
- From: Tim O'Neil <toneil@visigenic.com>
- Newsgroups: comp.lang.c
- Subject: Re: Function wanted to evaluate string
- Date: Fri, 16 Feb 1996 13:34:44 +0000
- Organization: Visigenic Software, Inc.
- Message-ID: <312487F4.6086@visigenic.com>
- References: <4g20eo$623@coranto.ucs.mun.ca>
- NNTP-Posting-Host: vsi48.visigenic.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b5 (WinNT; I)
-
- Chris Deacon wrote:
- >
- > I want a function which will evaluate a string of numbers and
- > arithmetic operators. That is, whwn I call
- > eval_func(2*5)
-
- > a value of 10 will be returned.
-
- > Ideally, I'd like the code to be able to handle several operators
- > in the string, so that
- > eval_func((3*5.7)/(2-.77)+4.5)
- > will be evaluated just as easily.
- > All suggestions gratefully appreciated..
-
- Look for string math libraries in your delopment enviroment. You might
- scan string.h for function prototypes. I would avoid string math if you
- can possibly do so however. Better to do the math with appropriate types
- and then map results to strings. (imho, anyway)
-